const{
  addFeedback
} =require('../../api/project')
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    project_id:0,
    project_name:'',
    feedback_ctx:'',
    fileList: [
      {
        url: 'https://img.yzcdn.cn/vant/leaf.jpg',
        status: 'uploading',
        message: '上传中',
      },
      {
        url: 'https://img.yzcdn.cn/vant/tree.jpg',
        status: 'failed',
        message: '上传失败',
      },
      {
        url: 'https://img.yzcdn.cn/vant/tree.jpg',
        name: '图片2',
        isImage: true,
        deletable: true,
      },
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      project_id: options.id,
      project_name: options.pn
    });
  },
  onChange(event) {
    this.setData({
      feedback_ctx: event.detail,
    });
  },
  submit(event) {
    var that = this
    addFeedback({uid:app.userInfo.id,feedback_ctx:this.data.feedback_ctx,project_id:this.data.project_id}).then(res=>{
      var pages = getCurrentPages(); //当前页面
      var beforePage = pages[pages.length - 2]; //前一页
      wx.navigateBack({
        success: function () {
          console.log('-------------222223333333-----------')
          console.log(that.data.project_name)
          beforePage.onLoad({pn:that.data.project_name,id:that.data.project_id}); // 执行前一个页面的onLoad方法
        }
      });
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})